﻿using Architecture.API.Application.TraceabilityCommand.BreedCommand;
using MediatR;
using Traceability.Domain.BreedDomain;
using Traceability.Domain.Service.BreedService;

namespace Architecture.API.Application.TraceabilityCommandHandler.BreedCommandHandler
{
    /// <summary>
    /// 养殖信息反填命令处理器
    /// </summary>
    public class BreedReverseCommandHandler : IRequestHandler<BreedReverseCommand, Breed>
    {
        /// <summary>
        /// 养殖服务
        /// </summary>
        protected readonly IBreedService breedService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="breedService">养殖服务</param>
        public BreedReverseCommandHandler(IBreedService breedService)
        {
            this.breedService = breedService;
        }

        /// <summary>
        /// 反填养殖信息
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Breed> Handle(BreedReverseCommand request, CancellationToken cancellationToken)
        {
            return await breedService.GetBreedModel(request.breedId);
        }
    }
}
